import java.util.Scanner;

public class OneModel {
    //一维前缀和模板
    public void code() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();

        int[] a = new int[n + 1];
        for (int i = 1; i < n + 1; i++){
            a[i] = in.nextInt();
        }

        //初始化一个前缀和数组
        long[] dp = new long[n + 1];
        for(int i = 1; i < n + 1; i++){
            dp[i] = dp[i - 1] + a[i];
        }

        while (q > 0){
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }
    }
}
